import mysql.connector.pooling

# config = {
#     "host": "localhost",
#     "port": 3306,
#     "user": "root",
#     "password": "1234",
#     "database": "canteen"
# }
# try:
#     pool = mysql.connector.pooling.MySQLConnectionPool(
#         **config,
#         pool_size=10
#     )
#     con = pool.get_connection()
#     # con.start_transaction()
#     cursor = con.cursor()
#     # sql="DELETE e,d FROM t_emp e JOIN t_dept d ON e.deptno=d.deptno " \
#     #     "WHERE d.deptno=20"
#     sql = "TRUNCATE TABLE t_emp"
#     cursor.execute(sql)
#     # con.commit()
# except Exception as e:
#     # if "con" in dir():
#     # con.rollback()
#     print(e)


config = {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "1234",
    "database": "canteen"
}

try:
    pool = mysql.connector.pooling.MySQLConnectionPool(
        **config,
        pool_size=10
    )
    con = pool.get_connection()
    con.start_transaction()
    cursor = con.cursor()
    sql = "DELETE e,d FROM t_emp e JOIN t_dept d ON e.deptno = d.deptno WHERE d.deptno=20"
    cursor.execute(sql)
    con.commit()
except Exception as e:
    print(e)
